package com.bdqn.hospital.mapper;

import com.bdqn.hospital.pojo.SysUsers;
import com.bdqn.hospital.pojo.SysUsers;
import org.apache.ibatis.annotations.Insert;
import com.bdqn.hospital.pojo.SysUsers;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @version : 1.0
 * @Author :guogd
 * @createTime: 2023/03/01 14:32
 * @Description: com.bdqn.hospital.mapper
 */
@Mapper
public interface SysUsersMapper {
    /**
     * 登录
     * @param account 用户名
     * @param password 密码
     * @return
     */
    @Select("SELECT * FROM sys_users WHERE account = #{account} AND password = #{password};")
    SysUsers logIn(@Param("account")String account, @Param("password") String password);

    /**
     * 根据用户id获取用户信息
     * @param
     * @return
     */
    SysUsers getByUserId(@Param("id") Integer id);

    /**
     * 查出门诊医师用户的姓名
     * @return
     */
    @Select("select * from `sys_users` where user_type =3 and department_id is not null")
    List<SysUsers> getUserName();

    /**
     * 鑾峰彇鎵€鏈夌敤鎴蜂俊鎭?
     */
    @Select("select * from `sys_users`")
    List<SysUsers> getAll();

    /**
     * 娣诲姞鐢ㄦ埛
     */
    @Insert("INSERT INTO `sys_users` VALUES (null,#{departmentId}, " +
            "#{userType},  " +
            "#{headUrl}, " +
            "#{account}, " +
            "#{userName},  " +
            "#{password}, " +
            "#{salt}," +
            "now()," +
            "null, " +
            "#{createdUserId})")
    Integer addUser(SysUsers users);
}
